﻿package com.wongoing.sys.service.impl;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wongoing.base.BaseServiceImpl;
import com.wongoing.base.PageResult;
import com.wongoing.sys.dao.SysNoticeDao;
import com.wongoing.sys.model.SysNotice;
import com.wongoing.sys.service.SysNoticeService;
import com.wongoing.sys.util.Constants;
import com.wongoing.util.DateConvert;

@Service("sysNoticeService")
@Transactional
public class SysNoticeServiceImpl extends BaseServiceImpl<SysNotice> implements SysNoticeService {
	private SysNoticeDao dao;

	@Autowired
	public void setDao(SysNoticeDao dao) {
		super.setDao(dao);
		this.dao = dao;
	}
	
	/**
	 * 功能说明：通过PageResult获取公告分页数据
	 * 修改说明：
	 * @author zhenglibing,吴兆强
	 * @date 2017年10月14日 下午9:33:36
	 * @param pageResult 分页查询对象，包含查询条件
	 * @return 返回分页查询对象，包含页面数据
	 */
	public PageResult<SysNotice> getNoticeListPageResult(PageResult<SysNotice> pageResult) {
		pageResult.getParam().put("offset", pageResult.getPageSize() * (pageResult.getPageCurrent() - 1));//当前页-1
		pageResult.getParam().put("limit", pageResult.getPageSize());
		if (!"".equals(pageResult.getOrderField())) 
		{ pageResult.getParam().put("orderColumn", pageResult.getOrderField()); }
		pageResult.getParam().put("orderTurn", pageResult.getOrderDirection());
		List<SysNotice> data = this.dao.getNoticeListByParam(pageResult.getParam());
		pageResult.setList(data);
		int totalSize = this.dao.countOfNoticeListByParam(pageResult.getParam());
		pageResult.setTotal(totalSize);
		return pageResult;
	}
}
